<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
<#include "/jeecms_sys/head.html"/>
<script type="text/javascript">
function getTableForm() {
	return document.getElementById('tableForm');
}
function optDelete() {
	if(Pn.checkedCount('ids')<=0) {
		$.alert("<@s.m 'global.prompt'/>","<@s.m 'error.checkRecord'/>");
		return;
	}
	$.confirm(doDelete,"<@s.m 'global.confirm'/>","<@s.m 'global.confirm.delete'/>");
}
function doDelete(){
	var f = getTableForm();
	f.action="o_delete.do";
	f.submit();
}
$(function() {
	$("#addForm").validate();
	$("#editForm").validate();
	$("#dialog-add-form").dialog({
		autoOpen: false,
		height: 300,
		width: 350,
		modal: true,
		buttons: {
			"<@s.m code='global.submit'/>": function() {
				$("#addForm").submit();
				var errorlength=$(".error").length;
				if(errorlength<0){
					$( this ).dialog( "close" );
				}
			},
			"<@s.m code='global.reset'/>": function() {
				$("#addForm")[0].reset();
			}
		}
	});
	$("#dialog-edit-form").dialog({
		autoOpen: false,
		height: 300,
		width: 350,
		modal: true,
		buttons: {
			"<@s.m code='global.submit'/>": function() {
				$("#editForm").submit();
				var errorlength=$(".error").length;
				if(errorlength<0){
					$( this ).dialog( "close" );
				}
			},
			"<@s.m code='global.reset'/>": function() {
				$("#editForm")[0].reset();
			}
		}
	});
	$(".add").click(function() {
		$( "#dialog-add-form" ).dialog("open");
	});
	$("a[id^='edit_']").click(function() {
		getData($(this).attr("id").split("edit_")[1]);//获取json数据  
		$( "#dialog-edit-form" ).dialog("open");
	});
});
function getData(id){
    $.getJSON("v_ajax_edit.do",{id:id},function(data){  
        $("#id").val(data.id);
        $("#name").val(data.name); 
        $("#priority").val(data.priority);
        $("#url").val(data.url);
  });  
}
</script>
</head>
<body>
<div class="box-positon">
	<div class="rpos"><@s.m "global.position"/>: <@s.m "cmsUser.menu.fuction"/> - <@s.m "global.list"/></div>
	<form class="ropt">
		<input class="add"  value="<@s.m "global.add"/>" />
	</form>
	<div class="clear"></div>
</div>
<div class="body-box">
<form id="tableForm" method="post">
<input type="hidden" name="pageNo" value="${pageNo!}"/>
<@p.table value=pagination;cmsUserMenu,i,has_next><#rt/>
	<@p.column title="<input type='checkbox' onclick='Pn.checkbox(\"ids\",this.checked)'/>" width="20">
		<input type='checkbox' name='ids' value='${cmsUserMenu.id}'/><#t/>
	</@p.column><#t/>
	<@p.column code="cmsUser.menu.name"><a href="${cmsUserMenu.url!}">${cmsUserMenu.name!}</a></@p.column><#t/>
	<@p.column code="cmsUser.menu.url">${cmsUserMenu.url!}</@p.column><#t/>
	<@p.column code="cmsUser.menu.priority">${cmsUserMenu.priority!}</@p.column><#t/>
	<@p.column code="global.operate" align="center">
		<a href="#" class="pn-opt" id="edit_${cmsUserMenu.id}"><@s.m "global.edit"/></a> | <#rt/>
		<a href="o_delete.do?ids=${cmsUserMenu.id}&pageNo=${pageNo!}" onclick="if(!$.confirmToUrl(this.href)) {return false;}"  class="pn-opt"><@s.m "global.delete"/></a><#t/>
	</@p.column><#t/>
</@p.table>
<div><input class="del-button" type="button" value="<@s.m "global.delete"/>" onclick="optDelete();"/></div>
</form>

<div id="dialog-add-form" title="<@s.m 'cmsUser.menu.fuction'/> - <@s.m 'global.add'/>">
	<@p.form id="addForm" action="o_save.do">
		<@p.text label="cmsUser.menu.name" name="name" required="true" class="required" maxlength="100"/>
		<@p.text label="cmsUser.menu.url" name="url" required="true" class="required" maxlength="100"/>
		<@p.text label="cmsUser.menu.priority" name="priority" required="true" class="required digits" maxlength="100"/>
	</@p.form>
</div>

<div id="dialog-edit-form" title="<@s.m 'cmsUser.menu.fuction'/> - <@s.m 'global.edit'/>">
	<@p.form id="editForm" action="o_update.do">
		<@p.text label="cmsUser.menu.name" name="name" id="name"  required="true" class="required" maxlength="100"/>
		<@p.text label="cmsUser.menu.url" name="url" id="url" required="true" class="required" maxlength="100"/>
		<@p.text label="cmsUser.menu.priority" name="priority" id="priority" required="true" class="required digits" maxlength="100"/>
	<@p.td>
		  <@p.hidden name="id" id="id"/>
	</@p.td>
	</@p.form>
</div>
</div>
<#include "/common/alert_message.html"/>
</body>
</html>